﻿@model ContactManagement.Models.UserListModel
@{
    ViewBag.Title = Resources.AdminViews.UserListRESX;
}
<h2>
    @Resources.AdminViews.UserListRESX</h2>
<p>
    @Html.ShowCustomMessage()
</p>

@Html.Paging().Create(Model.Users)

<table class="@WebConstants.FilterTableRowsCssClass">
    <thead>
        <tr>
            <th>@Resources.AccountViews.OptionsRESX
            </th>
            <th>
                @Html.TableHeaderLinks("UserTitle", Resources.AccountViews.TitleRESX).CreateSortLink()
            </th>
            <th>
                @Html.TableHeaderLinks("Firstname", Resources.AccountViews.FirstnameRESX).CreateSortLink()
            </th>
            <th>
                @Html.TableHeaderLinks("Lastname", Resources.AccountViews.LastnameRESX).CreateSortLink()
            </th>
            <th>
                @Html.TableHeaderLinks("LoginEmail", Resources.AccountViews.LoginnameRESX).CreateSortLink()
            </th>
            <th>
                @Html.TableHeaderLinks("UserCategory", Resources.AccountViews.UserCategoryRESX).CreateSortLink()
            </th>
            <th>@Resources.AccountViews.IsActiveRESX
            </th>
            <th>
                @Html.TableHeaderLinks("Creator", Resources.AdminViews.CreatorRESX).CreateSortLink()
            </th>
            <th>@Resources.AccountViews.LastLoginDateRESX
            </th>
        </tr>
    </thead>
    <tbody>
    @{ System.Diagnostics.Stopwatch time = new System.Diagnostics.Stopwatch(); }
    @{ System.Diagnostics.Stopwatch time2 = new System.Diagnostics.Stopwatch();
       time2.Start(); }
        @foreach (EFDataModel.EFUser eUser in Model.Users.CurrentPageEntriesOrderByUrl(WebConstants.PageSizePaging))
        {
            <tr data-id="@eUser.ID">
                <td>
                @{time.Start(); }
                   @if(WebRights.Right().Check(EFDataModel.Enums.EUserRights.UserDetails)) { @Html.ActionLink(Resources.Navigation.DetailsRESX, EActionUser.UserDetails.ToString(), new { id = eUser.ID }) }
                   @if(WebRights.Right().Check(EFDataModel.Enums.EUserRights.UserEdit)) { <text>|</text> @Html.ActionLink(Resources.Navigation.EditRESX, EActionUser.UserEdit.ToString(), new { id = eUser.ID }) }
                   @if(WebRights.Right().Check(EFDataModel.Enums.EUserRights.SetUserRights)) { <text>|</text> @Html.ActionLink(Resources.Navigation.EditUserRightsRESX, EActionUser.UserEditUserRights.ToString(), new { id = eUser.ID }) }
                   @if (WebRights.Right().Check(EFDataModel.Enums.EUserRights.SetUserGroups)) { <text>|</text> @Html.ActionLink(Resources.Navigation.EditUserGroupsRESX, EActionUser.UserEditUserGroups.ToString(), new { id = eUser.ID }) }
                
                </td>
                <td>@Html.Categories().DisplayForCategory(eUser.UserTitleID.ToString())
                </td>
                <td>@Html.DisplayFor(modelItem => eUser.Firstname)
                </td>
                <td>@Html.DisplayFor(modelItem => eUser.Lastname)
                </td>
                <td>@Html.DisplayFor(modelItem => eUser.LoginEmail)
                </td>
                <td>@Html.DisplayFor(modelItem => eUser.UserCategory.Name)
                </td>
                <td>
                    @{
            if (eUser.IsActiveUser)
            {
                        @Resources.GlobalStrings.YesRESX;
            }
            else
            {
                        @Resources.GlobalStrings.NoRESX;
            }
                    }
                </td>
                <td>
                    @{ //Der ersteller kann nur angezeigt werden, wenn dieser auch gesetzt wurde.
            if (eUser.CreatorID.HasValue)
            {
                        @eUser.Creator.GetFullName();
            }
            time.Stop();
            //EFDebugging.Debugging.WriteLog("DS: " + time.ElapsedMilliseconds + "\r\n");
              }
                </td>
                <td>@Html.DisplayFor(modelItem => eUser.LastLoginDate)
                </td>
            </tr>
                        
        }

        @{
            time2.Stop();
            EFDebugging.Debugging.WriteLog("Gesamt: " + time2.ElapsedMilliseconds + "\r\n");
            }
    </tbody>
</table>
<p>
    @Html.ActionLink(Resources.Navigation.BackToStartpageRESX, EActionHome.Index.ToString(), EControllers.Home.ToString())
</p>
